﻿using AdverseEventReportSystem.BLL.ServiceReference1;
using AdverseEventReportSystem.Utils;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace AdverseEventReportSystem.Web.Areas.Personnel
{
    public class PersonnelFileListController : BaseController
    {
        // GET: Personnel/PersonnelFileList
        public ActionResult Index()
        {
            return View();
        }

        /// <summary>
        /// 档案列表
        /// </summary>
        /// <returns></returns>
        public ActionResult Search()
        {
            int pageIndex = DataConvert.StrToInt(Request["page"], 1);
            int pageSize = DataConvert.StrToInt(Request["pageSize"], ConfigHelper.GetConfigInt("pagesize"));
            int inServiceStatus = DataConvert.StrToInt(Request["inServiceStatus"]);
            int hireType = DataConvert.StrToInt(Request["hireType"]);
            int status = DataConvert.StrToInt(Request["status"]);
            string startHeight = DataConvert.ToString(Request["startHeight"]);
            string endHeight = DataConvert.ToString(Request["endHeight"]);
            string startShoeSize = DataConvert.ToString(Request["startShoeSize"]);
            string endShoeSize = DataConvert.ToString(Request["endShoeSize"]);
            string startAge = DataConvert.ToString(Request["startAge"]);
            string endAge = DataConvert.ToString(Request["endAge"]);
            string name = DataConvert.ToString(Request["name"]);
            string areaId = DataConvert.ToString(Request["areaId"]);
            string sex = DataConvert.ToString(Request["sex"]);
            string zkhszsTitle = DataConvert.ToString(Request["zkhszsTitle"]);
            string nursingAge = DataConvert.ToString(Request["nursingAge"]);

            string departmentCode = "";
            if (areaId == "-1")
            {
                departmentCode = loginUser.DepartCode;
            }
            else
            {
                departmentCode = areaId;
            }

            FunctionAndPermissionsSoapClient service = new FunctionAndPermissionsSoapClient();
            ResultHelperOfSkip serviceResult = service.getP_PersonnelMS(pageIndex, pageSize, "", departmentCode, name, hireType, sex, inServiceStatus, zkhszsTitle, startHeight, endHeight, startShoeSize, endShoeSize, nursingAge, status, startAge, endAge);
            DataTable dt = new DataTable();
            int total = 0;
            if (serviceResult.S)
            {
                dt = serviceResult.D.DT;
                total = serviceResult.D.RowNum;
            }

            var result = new { Total = total, Rows = dt };
            return JsonDate(result);
        }
    }
}